package com.sakura.util.park;/**
 * Created by apple on 2019/9/29.
 */

import java.util.concurrent.locks.LockSupport;

/**
 * @author jixd
 * @Description
 * @Date 2019/9/29 12:07 AM
 * @Version 1.0
 **/
public class LockTest {
    private static class Test implements Runnable{

        Test(){
            System.out.println("构造器");
        }

        @Override
        public void run() {
            System.out.println("子线程运行");
            while (!Thread.currentThread().isInterrupted()){
                System.out.println("正常运行");
                LockSupport.park();
            }
            System.out.println("运行方法");
        }
    }

    public static void main(String[] args) {
//        Thread thread = new Thread(new T());
//        System.out.println("线程已创建");
//        thread.start();
//        new Thread(T::new).start();
        Thread thread = new Thread(Test::new);
        System.out.println("线程已创建");
        thread.start();


        try{
            Thread.sleep(2000);
        }catch (Exception e){

        }
        System.out.println("结束");
    }
}
